package com.example.kass.controller;

import com.example.kass.model.CorrectRequest;
import com.example.kass.service.CorrectTablesService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/api")
public class CorrectTablesController {
    @Autowired
    private CorrectTablesService correctTablesService;

    /**
     * 全库替换表中字段的数值
     *
     * @param request
     * @return
     */
    @RequestMapping("correct/table")
    public Object correct(CorrectRequest request) {
        correctTablesService.correct(null);
        return "success";
    }

    /**
     * 替换单张表
     *
     * @param tableName
     * @return
     */
    @RequestMapping("correct/table/{tableName}")
    public Object correct(@PathVariable("tableName") String tableName) {
        correctTablesService.correct(tableName);
        return "success";
    }
}
